import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      // 重定向到welcome页面
      redirect: { name: 'welcome' },
      children: [
        {
          path: '/welcome',
          name: 'welcome',
          component: () => import(/* webpackChunkName: "welcome" */ '../views/Welcome.vue')
        },
        {
          path: '/goods',
          name: 'goodsList',
          component: () => import(/* webpackChunkName: "goodsList" */ '../views/goods/GoodsList.vue')
        },
        {
          path: '/add',
          name: 'add',
          component: () => import(/* webpackChunkName: "add" */ '../views/goods/addGoods.vue')
        },
        // 权限管理路由
        {
          path: '/roles',
          name: 'roles',
          component: () => import(/* webpackChunkName: "roles" */ '../views/auth/Roles.vue')
        },
        {
          path: '/rights',
          name: 'rights',
          component: () => import(/* webpackChunkName: "rights" */ '../views/auth/Rights.vue')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import(/* webpackChunkName: "login" */ '../views/Login.vue')
    }

  ]
})
